import 'package:finance_app/src/entities/delivery_entity.dart';

deliveryEntityFromJson(DeliveryEntity data, Map<String, dynamic> json) {
	if (json['data_type'] != null) {
		data.dataType = json['data_type'].toString();
	}
	if (json['id'] != null) {
		data.id = json['id'] is String
				? int.tryParse(json['id'])
				: json['id'].toInt();
	}
	if (json['company_id'] != null) {
		data.companyId = json['company_id'] is String
				? int.tryParse(json['company_id'])
				: json['company_id'].toInt();
	}
	if (json['deliverable_type'] != null) {
		data.deliverableType = json['deliverable_type'].toString();
	}
	if (json['deliverable_id'] != null) {
		data.deliverableId = json['deliverable_id'] is String
				? int.tryParse(json['deliverable_id'])
				: json['deliverable_id'].toInt();
	}
	if (json['poc_name'] != null) {
		data.pocName = json['poc_name'];
	}
	if (json['poc_phone_number'] != null) {
		data.pocPhoneNumber = json['poc_phone_number'];
	}
	if (json['address_country'] != null) {
		data.addressCountry = json['address_country'].toString();
	}
	if (json['address_city'] != null) {
		data.addressCity = json['address_city'].toString();
	}
	if (json['address_postal_code'] != null) {
		data.addressPostalCode = json['address_postal_code'].toString();
	}
	if (json['address_line_1'] != null) {
		data.addressLine1 = json['address_line_1'].toString();
	}
	if (json['address_line_2'] != null) {
		data.addressLine2 = json['address_line_2'];
	}
	if (json['address_unit'] != null) {
		data.addressUnit = json['address_unit'].toString();
	}
	if (json['status'] != null) {
		data.status = json['status'].toString();
	}
	return data;
}

Map<String, dynamic> deliveryEntityToJson(DeliveryEntity entity) {
	final Map<String, dynamic> data = new Map<String, dynamic>();
	data['data_type'] = entity.dataType;
	data['id'] = entity.id;
	data['company_id'] = entity.companyId;
	data['deliverable_type'] = entity.deliverableType;
	data['deliverable_id'] = entity.deliverableId;
	data['poc_name'] = entity.pocName;
	data['poc_phone_number'] = entity.pocPhoneNumber;
	data['address_country'] = entity.addressCountry;
	data['address_city'] = entity.addressCity;
	data['address_postal_code'] = entity.addressPostalCode;
	data['address_line_1'] = entity.addressLine1;
	data['address_line_2'] = entity.addressLine2;
	data['address_unit'] = entity.addressUnit;
	data['status'] = entity.status;
	return data;
}